import { getUserInfoApi } from '../../api/user.js'
export default {
  namespaced: true,
  state: {
    userInfo: {}
  },
  mutations: {
    setUserInfo (state, data) {
      state.userInfo = data
    }
  },
  getters: {
    avatar (state) {
      // return state.userInfo.user_pic
      //   ? state.userInfo.user_pic
      //   : state.userInfo.username.charAt(0).toUpperCase()
      return state.userInfo.username
        ? state.userInfo.username.charAt(0).toUpperCase()
        : ''
    }
  },
  actions: {
    async AgetUserInfo ({ commit }) {
      const res = await getUserInfoApi()
      commit('setUserInfo', res.data.data)
    }
  }
}
